<?php  # Script -- test.php

/* Author @ Huoty
 *   Date @ 2015-11-25 14:15:15
 *  Brief @ 
 */

//从URL中获取主机名称
preg_match('@^(?:http://)?([^/]+)@i',
    "http://www.php.net/index.html", $matches);
$host = $matches[1];
echo $host . '<br/>';

//获取主机名称的后面两部分
preg_match('/[^.]+[^.]+$/', $host, $matches);
echo "domain name is: {$matches[0]} ";

?>
